/**
 * Offline Mode  离线模式
 * First, subscribe with QoS 1 and disconnect
 * 首先，订阅服务QoS 1并之后断开连接
 */

var mqtt = require('mqtt');

var settings = {
  keepalive: 10,
  protocolId: 'MQIsdp',
  protocolVersion: 3,
  clientId: 'client-b',
  clean: false
}

client = mqtt.createClient(1883, 'localhost',settings);

client.subscribe('testMessage',{qos:1},function(){
  console.log('subscribe ok.');
  client.end();
});




// var mqtt = require('mqtt'); 
// var settings ={
//   host: 'localhost', 
//   port: 1883, 
//   clientId: "client-c", 
//   clean: false};
// client = mqtt.connect(settings);
// client.subscribe("mqtt/offline", { qos: 1 },function() {
//   console.log("subscribe done!");
//   client.end();
// });

